package com.hziee.cosmanage.member.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.hziee.cosmanage.member.entity.ViolationEntity;
import com.hziee.cosmanage.member.service.ViolationService;
import com.hziee.common.utils.PageUtils;
import com.hziee.common.utils.R;



/**
 * 
 *
 * @author yb
 * @email yangbin@gmail.com
 * @date 2021-02-02 22:48:30
 */
@RestController
@RequestMapping("member/violation")
public class ViolationController {
    @Autowired
    private ViolationService violationService;

    /**
     * 用户违纪远程调用接口
     * @return
     */
    @PostMapping("/personViolation")
    public R personViolation(@RequestBody ViolationEntity violationEntity){
        violationService.personViolation(violationEntity);
        return R.ok();
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("member:violation:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = violationService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{violationId}")
    //@RequiresPermissions("member:violation:info")
    public R info(@PathVariable("violationId") Integer violationId){
		ViolationEntity violation = violationService.getById(violationId);

        return R.ok().put("violation", violation);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("member:violation:save")
    public R save(@RequestBody ViolationEntity violation){
		violationService.save(violation);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
   // @RequiresPermissions("member:violation:update")
    public R update(@RequestBody ViolationEntity violation){
		violationService.updateById(violation);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("member:violation:delete")
    public R delete(@RequestBody Integer[] violationIds){
		violationService.removeByIds(Arrays.asList(violationIds));

        return R.ok();
    }

}
